<template>
  <div class="home">
      <div>
          <h1>登录首页 </h1>
      </div>
      <div>
         当前登录用户：{{username}}  <a href="javascript:void(0);" @click="logout" >注销</a>
      </div>
      <div>
        <router-link to="/fukuan">收付款</router-link> | <router-link to="/setorder">收款扫码</router-link>
      </div>
  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'

export default {
  name: 'HomeView',
  components: {
    HelloWorld
  },
  data(){
    return{
      username:""
    }
  },
  mounted(){
    //页面加载的时候调用的方法
    console.log(JSON.parse(localStorage.getItem('loginUser')));
    this.username = JSON.parse(localStorage.getItem('loginUser')).username;
  },
  methods:{
    //注销用户状态方法
    logout(){
      // 清除状态保持
      window.localStorage.clear();
      // 状态保持清除后刷新页面
      window.location.reload();
    }
  }
}
</script>
